package ai.people.core.security.config;

import ai.people.core.security.exception.handler.UAAExceptionHandler;
import ai.people.core.security.intercept.RequestSecurityInterceptor;
import ai.people.core.security.properties.CloudSecurityProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Import;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 云安全拦截器配置
 *
 * @author yuanqinglong
 * @date 2022/2/15 16:19
 */
@Import(UAAExceptionHandler.class)
@EnableConfigurationProperties(CloudSecurityProperties.class)
public class CloudSecurityInterceptorConfiguration implements WebMvcConfigurer {


    @Autowired
    private CloudSecurityProperties cloudSecurityProperties;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new RequestSecurityInterceptor(cloudSecurityProperties));
    }
}
